import BaseUserHttp from "./BaseUserHttp";'./BaseUserHttp.js'

const getSMSCode = (mobile) => {
    const path = "/user/smscode/" + mobile;
    return BaseUserHttp.get(path)
}

const login = (mobile, code) => {
    const path = "/user/login";
    const data = {
        mobile,
        code,
    }
    return BaseUserHttp.post(path, data)
}

const logout = () => {
    const path = "/user/logout";
    const data = {}
    return BaseUserHttp.post(path)
}

const updateUsername = (username) => {
    const path = "/user/update/username";
    const data = {
        username: username,
    }
    return BaseUserHttp.put(path, data)
}

const createAddress = (data) =>{
    const path = "/address/create";
    return BaseUserHttp.post(path, data)
}

const getAddressList = (page=1, size=10) => {
    const path = "/address/list?page=" + page + "&size=" + size;
    return BaseUserHttp.get(path);
}

const deleteAddress = (address_id) => {
    const path = "/address/delete"
    const data = {
        address_id,
    }
    return BaseUserHttp.delete(path, data);
}
export default {
    getSMSCode,
    login,
    logout,
    updateUsername,
    createAddress,
    getAddressList
}